'use strict';
const db = uniCloud.database()

exports.add = async (data) => {
  const collection = db.collection('imagesBase');

  // let article = await collection.where({
  let artile = await collection.where({
    images: data.images
  }).get() // 切记获取最后一定要 get()
  // })
  if (artile.affectedDocs < 1) {
    const res = await collection.add({
      name: data.name,
      images: data.images,
    })
    return {
      code: global.successCode,
      msg: '提交成功'
    }
  } else {
    return {
      code: global.wrongCode,
      msg: '图片不能重复，请重新上传'
    }
  }



}
